<template>
  <view>
    <view class="hrader">
      <image
        src="../../../static/bback.png"
        class="goback"
        @click="gobackClick"
        mode=""
      />
      我的钱包
    </view>
    <view class="" style="padding-top: 88rpx">
      <navigator url="../myWallet/myWallet" class="box">
        <view class="title">余额</view>
        <view class="amount">￥{{ obj.money }}</view>
        <image
          src="../../../static/PersonalCenter/right.png"
          mode="widthFix"
          style="width: 12rpx"
        ></image>
      </navigator>
      <!-- <navigator url="../bankcard/bankcard" class="box">
        <image
          src="../../../static/user/a3.png"
          mode="widthFix"
          style="width: 46rpx"
        ></image>
        <view class="title">银行卡</view>

        <image
          src="../../../static/PersonalCenter/right.png"
          mode="widthFix"
          style="width: 12rpx"
        ></image>
      </navigator> -->
      <view class="box" @click="setPaym">
        <view class="title">设置支付密码</view>
        <image
          src="../../../static/PersonalCenter/right.png"
          mode="widthFix"
          style="width: 12rpx"
        ></image>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      token: "",
      obj: {},
    };
  },
  onShow() {
    this.token = uni.getStorageSync("token");
    if (this.token) {
      this.myWallet();
      this.getuserInfo();
    }
  },
  methods: {
    gobackClick() {
      uni.navigateBack({
        delta: 1,
      });
    },
    // 获取用户信息
    async getuserInfo() {
      let that = this;
      const res = await that.$myRequest({
        url: "user/getUserInfo",
        method: "GET",
        data: {},
      });
      if (res.data.code == 1) {
        that.userInfo = res.data.data;
        uni.setStorageSync("userInfo", res.data.data);
      }
    },
    // 我的钱包
    async myWallet() {
      let that = this;
      const res = await that.$myRequest({
        url: "user/myWallet",
        method: "POST",
        header: {
          token: that.token,
        },
        data: {},
      });
      if (res.data.code == 1) {
        that.obj = res.data.data;
      }
    },
    // 设置支付密码
    setPaym() {
      if (this.userInfo.mobile) {
        uni.navigateTo({
          url: "../Setpassword/Setpassword",
        });
      } else {
        // 显示加载中 效果
        uni.showLoading({
          title: "请先绑定手机号",
          mask: true,
        });
        setTimeout(function () {
          uni.navigateTo({
            url: "../binding/binding",
          });
        }, 800);
      }
    },
  },
};
</script>

<style lang="scss">
page {
  background: #f4f4f4;
  min-height: 100vh;
  position: relative;
}
.hrader {
  width: 100%;
  height: 88rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  position: relative;
  font-size: 36rpx;
  font-weight: 500;
  color: #333333;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 99;
  .goback {
    position: absolute;
    width: 22rpx;
    height: 34rpx;
    left: 28rpx;
  }
}
.box {
  height: 102rpx;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 30rpx;
  background-color: #ffffff;
  margin: 20rpx auto;
  .title {
    flex: 1;
    font-size: 30rpx;
    font-weight: 400;
    color: #333333;
  }
  .amount {
    padding-right: 16rpx;
    font-size: 28rpx;
    color: #666666;
  }
}
</style>
